package com.fromfuture.xuhuidoc.android.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.WindowManager;

import com.fromfuture.xuhuidoc.R;
import com.fromfuture.xuhuidoc.android.base.MyWebview;
import com.fromfuture.xuhuidoc.android.commonresouce.MyHtml;
import com.fromfuture.xuhuidoc.android.utils.MySharedPreferencesUtils;

import app.auto.runner.base.intf.FunCallback;

public class LoginActivity extends AppCompatActivity {
    public static void checkLogin(Activity aty, FunCallback func) {
        if (MySharedPreferencesUtils.getValue(aty, "DOCINFO", "DOCPHONE", "").length() == 0 || MySharedPreferencesUtils.getValue(aty, "DOCINFO", "DOCGUID", "").length() == 0) {
            Intent intent = new Intent(aty, LoginActivity.class);
            aty.startActivity(intent);
            aty.finish();
        } else {
            if (func != null) {
                func.simpleRun(aty);
            }
        }
    }

    private MyWebview myWebview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
        init();
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        android.os.Process.killProcess(android.os.Process.myPid());
    }

    private void init() {
        myWebview = (MyWebview) findViewById(R.id.login_webview);
        myWebview.loadUrl(MyHtml.LOGIN);
    }
}
